---
version: '2'

services:

{% for ca in cas %}
  {{ ca.name }}:
    container_name: {{ ca.name}}
    image: hyperledger/fabric-ca:{{ catag }}
    network_mode: bridge
    hostname: {{ ca.name}}
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server-config/ca
      - FABRIC_CA_SERVER_CA_NAME={{ ca.name}}
      - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/ca/{{ cakeys[ca.org+'_ca'] }}
      - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca/ca.{{ ca.org }}-cert.pem
{% if fabric.tls %}
      - FABRIC_CA_SERVER_TLS_ENABLED=true
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/tlsca/{{ cakeys[ca.org+'_tlsca'] }}
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/tlsca/tlsca.{{ ca.org }}-cert.pem
{% endif %}
    volumes:
      - {{ fabricworkdir }}/run/keyfiles/{{ ca.org }}:/etc/hyperledger/fabric-ca-server-config
    command: fabric-ca-server start -b {{ fabric.ca.admin }}:{{ fabric.ca.adminpw }} -d
{% endfor %}
